package com.cn.dao.impl;

import com.cn.dao.UserDao;
import com.cn.domain.User;
import com.cn.domain.UserAndRole;
import com.cn.domain.UserDetail;
import com.cn.utils.MysqlBaseImpl;
import org.springframework.stereotype.Repository;

/**
 * Created by chenyuncong on 2019/9/16.
 */
@Repository
public class UserDaoImpl extends MysqlBaseImpl<User> implements UserDao {
    public Long saveUserAndRole(UserAndRole userAndRole){
        return this.save(userAndRole,"insert into sys_user_role(user_id,role_id) values(:user_id,:role_id)");
    }

    public UserDetail getUserDetail(String name) throws Exception {
        return this.get("select u.id,u.name username,u.password from sys_user u where u.name=?",UserDetail.class,name);
    }


}
